﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace LED_Tester
{
    class ClassPrintPreviewDialogEx : PrintPreviewDialog
    {
        public ClassPrintPreviewDialogEx()
        {
            foreach (Control ctrl in base.Controls)
            {
                if (ctrl.GetType() == typeof(ToolStrip))
                {
                    ToolStrip tools = ctrl as ToolStrip;
                    tools.Items.RemoveAt(0);
                    tools.Items.Insert(0, CreatePrintsetButton());
                }
            }
        }

        ToolStripButton CreatePrintsetButton()
        {
            ToolStripButton stripbutton = new ToolStripButton();
            stripbutton.DisplayStyle = ToolStripItemDisplayStyle.Image;
            //stripbutton.Image = LED_Tester.Properties.Resources.print;
            stripbutton.Click += new EventHandler(stripbutton_Click);
            return stripbutton;
        }

        private void stripbutton_Click(object sender, EventArgs e)
        {
            PrintDialog diag = new PrintDialog();
            diag.Document = base.Document;
            if (diag.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    diag.Document.Print();
                }
                catch
                { }
            }
        }
    }
}
